<?php
/**
* @version		$Id: OdabirPonude.php 11 2011-11-01 17:18:58Z netix.mail@gmail.com $
* @package		ALM Hotel Menager	
* @subpackage	com_almhm
* @author		ALM Studio
* @copyright	Copyright 2011 ALM Studio. All rights reserved
* @licence		Commercial
*/

defined('_JEXEC') or die('Restricted access');

jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');

class JFormFieldOdabirPonude extends JFormFieldList
{
	protected $type = 'OdabirPonude';

	protected function getOptions() 
	{
		$options = array();
		
		$db	= JFactory::getDbo();
		$query	= $db->getQuery(true);
		$query->select('PonudaId AS value, PonudaNaziv AS text');
		$query->from('#__almhm_ponude');
		$query->order('PonudaNaziv ASC');
		$db->setQuery($query);

		$options = $db->loadObjectList();

		if ($db->getErrorNum()) {
			JError::raiseWarning(500, $db->getErrorMsg());
		}

		array_unshift($options, JHtml::_('select.option', '0', JText::_('COM_ALMHM_PONUDE_LIST')));

		return $options;
	}
}
